package com.campus.academic.controller;

import com.campus.academic.job.dto.InputGradesDTO;
import com.campus.academic.job.entity.Grades;
import com.campus.academic.job.entity.LearningResources;
import com.campus.academic.job.vo.StudentsGradesVO;
import com.campus.academic.service.IGradesService;
import com.campus.common.result.Result;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/academicGrade")
@Tag(name = "学生成绩服务")
public class GradeController {

    @Autowired
    private IGradesService gradesService;



    @ApiOperation(value = "查看某门考试的学生成绩")
    @GetMapping("/score")
    public Result<List<StudentsGradesVO>> getGrade(@RequestParam("courseId") Integer courseId) {
        List<StudentsGradesVO> list = gradesService.getGrade(courseId);
        return Result.success(list);
    }

    @ApiOperation(value = "录入学生成绩")
    @PutMapping("/input")
    public Result<List<StudentsGradesVO>> inputGrades(@RequestBody InputGradesDTO inputGradesDTO) {

        List<StudentsGradesVO> list = gradesService.inputGrades(inputGradesDTO.getCourseId(), inputGradesDTO.getExamScore(),inputGradesDTO.getUsualScore());
        return Result.success(list);
    }

    @ApiOperation(value = "学生获取成绩单")
    @GetMapping("/stu-scores")
    public Result getStuGrades () {
        return gradesService.getStuGrades();
    }
}
